<?php
namespace app\admin\controller;

use think\Db;
use app\admin\controller\Common;

class PhotoAlbum extends Common
{
    public function index()
    {
        $where = $or = [];
        if (input('?get.type')) {
            $type = input('get.type/s', '');
            if ($type == 'today') {
                $where[] = ['', 'exp',  Db::raw('FROM_UNIXTIME(`p`.`pay_time`,\'%Y-%m-%d\') = \''.date('Y-m-d').'\'')];
            } elseif ($text = input('get.text/d', 0)) {
                $or = [['p.'.$type, '=', $text, 'orWhere'], ['p.view_'.$type, '=', $text]];
            }
        }
        $photoModel = model('common/photo/Pay');
        $data = $photoModel->getAlbumList($where, $or);
        $this->assign('data', $data);
        $this->assign('page', $photoModel->page_info->render());
        return $this->fetch();
    }

    public function photo()
    {
        $where = $or = [];
        if (input('?get.type')) {
            $type = input('get.type/s', '');
            if ($type == 'today') {
                $where[] = ['', 'exp',  Db::raw('FROM_UNIXTIME(`p`.`pay_time`,\'%Y-%m-%d\') = \''.date('Y-m-d').'\'')];
            } elseif ($text = input('get.text/d', 0)) {
                if ($type == 'member_id') {
                    $or = [['p.'.$type, '=', $text, 'orWhere'], ['p.view_'.$type, '=', $text]];
                } else {
                    $where[] = ['p.'.$type, '=', $text];
                }
            }
        }
        $photoModel = model('common/photo/Pay');
        $data = $photoModel->getPhotoList($where, $or);
        $this->assign('data', $data);
        $this->assign('page', $photoModel->page_info->render());
        return $this->fetch();
    }
}